#include "CStopWatch.h"

#include <windows.h>

double CStopWatch::LIToSecs(LARGE_INTEGER & L) {
	return ((double)L.QuadPart / (double)frequency.QuadPart);
}

CStopWatch::CStopWatch(){
	timer.start.QuadPart = 0;
	timer.stop.QuadPart = 0;
	QueryPerformanceFrequency(&frequency);
}

void CStopWatch::startTimer() {
	QueryPerformanceCounter(&timer.start);
}

void CStopWatch::stopTimer() {
	QueryPerformanceCounter(&timer.stop);
}

double CStopWatch::getElapsedTime() {
	LARGE_INTEGER time;
	time.QuadPart = timer.stop.QuadPart - timer.start.QuadPart;
	return LIToSecs(time)*1000000;
}
